package cn.jboa.listener;

import java.util.List;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import cn.jboa.entity.Privilege;
import cn.jboa.service.IPrivilegeService;
//Servlet

public class InitListener implements ServletContextListener{

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		ApplicationContext ac=WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
		IPrivilegeService service=(IPrivilegeService)ac.getBean("privilegeServiceImpl");
		List<Privilege> all = service.findAll();
		sce.getServletContext().setAttribute("all",all );
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		
		
	}

}
